﻿@model Model.OriginalRecord.E_tb_OriginalRecord
@{
    ViewBag.Title = "OriginalRecordAdd";
}
<!DOCTYPE html>

<head>
    <meta name="viewport" content="width=device-width" />
    <title>原始记录信息</title>
    @*<script src="../../Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>*@
</head>
<body>
    @using (Ajax.BeginForm("Save", "OriginalRecord", new AjaxOptions { HttpMethod = "Post", OnSuccess = "handle", OnFailure = "failed" }, new { @id = "frmUpdate" }))
    {
        @Html.HiddenFor(m => m.RecordID, new { @id = "HidRecordID" })
        @Html.HiddenFor(m => m.EditType, new { @id = "HidEditType" })
        @Html.HiddenFor(m => m.FilePath, new { @id = "HidFilePath" })
        @Html.HiddenFor(m => m.DetectPersonnelID, new { @id = "HidDetectPersonnelID" }) <!--通过Js进行赋值-->
        @Html.HiddenFor(m => m.DetectTime, new { @id = "HidDetectTime" })
        <table border="0" cellpadding="0" cellspacing="0" width="98%" class="DialogTable">
            <tr>
                <td width="70px" align="right">样品名称：</td>
                <td align="left" style="width: 160px;">@Html.DropDownListFor(m => m.SampleID, ViewData["SampleList"] as SelectList, new { @id = "drop_Sample", @style = "width:160px;" })</td>
                <td width="70px" align="right">项目名称：</td>
                <td align="left" style="width: 160px;">@Html.DropDownListFor(m => m.ProjectID, ViewData["ProjectList"] as SelectList, new { @id = "drop_Project", @style = "width:160px;" })</td>
                <td width="70px" align="right">任务单号</td>
                <td align="left" style="width: 160px;">@Html.DropDownListFor(m => m.TaskNo, ViewData["ExpePlanList"] as SelectList)</td>
                <td rowspan="2" valign="top" align="right"></td>
            </tr>
            <tr style="display: none;">
                <td></td>
            </tr>
            <!--根据需求，去除该列-->
            <tr>
                @*<td width="70px" align="right">任务单号：</td>
                    <td align="left" style="width:160px;">@Html.DropDownListFor(m => m.TaskNo, ViewData["ExpePlanList"] as SelectList)</td>*@
                <td width="70px" align="right">检测日期：</td>
                <td align="left" style="width: 120px;">@Html.TextBoxFor(m => m.DetectTime, new { @style = "width:98%;", @id = "txt_DetectTime", @onclick = "WdatePicker()", @disabled = "disabled" })</td>
                <td width="70px" align="right">备注：</td>
                <td align="left" colspan="3">@Html.TextBoxFor(m => m.Contents, new { @style = "width:99%;", @id = "txt_Contents" })</td>
            </tr>
            <tr>
                <td colspan="6">
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <td width="70px" align="right">检验人：</td>
                            <td align="left" style="width: 110px;">
                                @Html.TextBoxFor(m => m.DetectPersonnelName, new { @style = "width:98%;", @id = "txt_DetectPersonnelName", @disabled = "disabled" })
                            </td>
                            <td>
                                检验标准：@Html.DropDownListFor(m => m.InsStand, ViewData["InsStandList"] as SelectList, new { @style = "width:160px;" })
                            </td>
                            <td align="right">
                                <input type="button" id="Btn_Detect" value="检验" style="width:80px" onclick="Detect('@ViewBag.DetectPersonnelID    ','@ViewBag.DetectPersonnelName    ')" /></td>
                            
                            <td rowspan="2" valign="top" align="right">
                                <input type="button" id="btn_Save" value="保存" style="width:80px" onclick="$('#frmUpdate').submit()" />
                                <a href="/UpFile/@ViewBag.FilePath">导出Execl</a>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="7" style="height: 700px;">
                    <!--阅览OFFICE-->
                    @Html.Raw(ViewBag.EditorHtml)
                </td>
            </tr>

            <tr>
                <td colspan="7" align="center">
                    <a href="javascript:void(0)" onclick="$('#frmUpdate').submit()">
                        <img src="~/Content/Images/baocun.png" height="20px" /></a>
                    <a href="javascript:void(0)" onclick="Close()">
                        <img src="~/Content/Images/quxiao.png" height="20px" /></a>
                </td>
            </tr>
        </table>
    }

    <script type="text/javascript">
        //检验人赋值
        function Detect(DetectPersonnelID, DetectPersonnelName) {
            $("#HidDetectPersonnelID").val(DetectPersonnelID);
            $("#txt_DetectPersonnelName").val(DetectPersonnelName);
        }

        //根据样品名称，加载对应项目列表
        function LoadProjectList() {
            var SampleID = $("#drop_Sample").val();
            $.ajax({
                async: false,
                type: "get",
                url: "/OriginalRecord/GetProjectList?SampleID=" + SampleID,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var optionlist = eval(data);
                    var OptionHtml = "";
                    for (var i = 0; i < optionlist.length; i++) {
                        OptionHtml += "<option value=\"" + optionlist[i].ProjectID + "\">" + optionlist[i].ProjectName + "</option>"
                    }
                    $("#drop_Project").html(OptionHtml);
                }
            });
        }

        function LoadTaskList()
        {
            $("#TaskNo").html("");
            var ProjectID = $("#drop_Project").val();
            var SampleID = $("#drop_Sample").val();
            $.ajax({
                async: false,
                type: "get",
                url: "/OriginalRecord/GetTaskList?ProjectID=" + ProjectID+"&SampleID="+SampleID,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var optionlist = eval(data);
                    var OptionHtml = "";
                    for (var i = 0; i < optionlist.length; i++) {
                        OptionHtml += "<option value=\"" + optionlist[i].ProjectID + "\">" + optionlist[i].ProjectName + "</option>"
                    }
                    $("#drop_Project").html(OptionHtml);
                }
            });
        }

        $(document).ready(function () {
            //LoadProjectList();
            //LoadTaskList();
            $("#drop_Sample").change(function () {
                LoadProjectList(); //根据样品名称，加载对应项目列表
                var SampleID = $("#drop_Sample").val();
                var ProjectID = $("#drop_Project").val();
                AddRef(ProjectID, SampleID);
            });

            $("#drop_Project").change(function () {
                var SampleID = $("#drop_Sample").val();
                var ProjectID = $("#drop_Project").val();
                LoadTaskList();
                AddRef(ProjectID, SampleID);
            });

            if ($("#HidEditType").val() == "Edit") {
                var SampleID='@ViewBag.SampleID';
            var ProjectID='@ViewBag.ProjectID';
            $("#drop_Sample").val(SampleID);
            LoadProjectList();
            $("#drop_Project").val(ProjectID);
        }
    });

    </script>
</body>
